<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>发型师提成规则配置</title>
<script type="text/javascript">
	$("#grid").jqGrid({
		pager:"#pager",
		url:"management/rolecommisionrule/page",
		datatype: "json",  //请求的数据类型
	   	colNames:["角色名称","金额范围","提成比例（%）","操作"],
	   	colModel:[
	   		{name:"roleName"},
	   		{name:"range",formatter:function(cellvalue, options, row){
	   			var text = "["+row.beginVal+"-"+row.endVal+")";
	   			return text;
	   		}},
	   		{name:"commisionRatio"},
	   		{name:"ctrl",formatter:function(cellvalue, options, row){
	   			var btns = "<div class='am-btn-group am-btn-group-xs'>";
	   			btns+="<a href='management/rolecommisionrule/edit/"+row.roleCommisionRuleId+"' class='am-btn am-btn-default' title='修改'><span class='am-icon-edit'></span> 修改</a>";
	   			if(row.roleCommisionRuleId == "${maxVal.roleCommisionRuleId}"){//最大值
	   				btns+="<button type='button' class='am-btn am-btn-default' title='删除' onclick='delRow(\""+row.roleCommisionRuleId+"\")'><span class='am-icon-trash'></span> 删除</button>";
	   			}else{
	   				btns+="<button type='button' class='am-btn am-btn-default' title='删除' disabled='disabled'><span class='am-icon-trash'></span> 删除</button>";
	   			}
	   			btns+="</div>";
	   			return btns;
	   		}},
	   	]
	});
	function delRow(id){
		if (id == "") {
			layer.msg("请选择删除项！！");
			return;
		}
		layer.confirm('是否删除？', function(index) {
			var url = "management/rolecommisionrule/delete/"+id;
			$.ajax({
				type : 'POST',
				url : url,
				dataType : 'json',
				success : function(data) {
					layer.msg(data.msg);
					if (data.success) {
						$("#grid").jqGrid().trigger("reloadGrid"); //重新载入 
					}
				}
			});
		});
	}
</script>
</head>

<body>
	<ol class="am-breadcrumb am-breadcrumb-slash am-padding" style="margin-bottom: 0px;">
		<li><a href="management/index">首页</a></li>
		<li class="am-active">发型师提成规则配置</li>
	</ol>
	<div class="am-g">
		<div class="am-u-md-8">
			<div class="am-btn-toolbar">
				<div class="am-btn-group am-btn-group-sm">
					<a href="management/rolecommisionrule/add" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
				</div>
			</div>
		</div>
	</div>
	<div class="am-g am-padding-vertical">
		<div class="am-u-md-12"><table id="grid"></table><div id="pager"></div></div>
	</div>
</body>
</html>
